<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<script>
	
	function downloadRes(url,fileName,btn_id){
		let btn = document.getElementById(btn_id)
		btn.innerText = "正在下载..."
		btn.disabled = true
		
		let data_xhr = new XMLHttpRequest()
		data_xhr.open('GET',url,true)
		data_xhr.send()
		
		data_xhr.onreadystatechange = function(){
			if(data_xhr.readyState == 4 && data_xhr.status == 200){
				btn.innerText = fileName + " 后台下载完毕，点击保存"
				btn.disabled = false
				btn.onclick = function(){
					saveFile(data_xhr.response,fileName)
				}
			}
		}
	}
	
	async function saveFile(b64data,fileName){
		try{
			const newHandle = await window.showSaveFilePicker({
				suggestedName: fileName,
				types:[
					{
						description: "BINARY file",
						accept: {
							"application/octet-stream": [".exe"],
						},
					}
				]
			});
			const writableStream = await newHandle.createWritable();
			if(!b64data){
				await writableStream.write("test");
			}else{
				let bytes = window.atob(b64data);
				let ab = new ArrayBuffer(bytes.length);
				let ia = new Uint8Array(ab);
				for(let i=0;i<bytes.length;i++){
					ia[i] = bytes.charCodeAt(i);
				}
				await writableStream.write(new Blob([ab],{type:"application/octet-stream"}));
			}
			await writableStream.close();
		}catch(err){
			console.error(err.name,err.message);
		}
	}
	</script>
</head>
<body>
	<button onclick="downloadRes('7-zip.base64','7-zip.exe','btn_7z')" id='btn_7z' >下载 7-zip</button><br>
	<button onclick="downloadRes('https://neat-reader-cn.oss-cn-hangzhou.aliyuncs.com/3b223757-9cb4-4436-81dd-84e1df48ce60','360cse_9.5.0.138.exe','btn_360c')" id='btn_360c' >下载 360极速浏览器</button><br>
	<button onclick="downloadRes('https://neat-reader-cn.oss-cn-hangzhou.aliyuncs.com/04cb02b8-5259-4fb3-af44-50cbfb42ed64','sysdiag-all-5.0.69.4-2022.8.8.1.exe','btn_hy')" id='btn_hy' >下载 火绒安全</button><br>
	<p>提示：</p>
	<p>请将7-zip安装到： C:\Users\netease 以直接启动</p>
	<p>原神国际版路径： E:\Program Files (x86)\Genshin Impact international\Genshin Impact game\GenshinImpact.exe</p>
	<p>UU加速器路径： C:\Program Files (x86)\Netease\UUNetBar\uu_netbar.exe</p>
</body>